//
//  Button.swift
//  HR
//
//  Created by zhenyu on 17/6/24.
//  Copyright © 2017年 allblue. All rights reserved.
//

import UIKit

class Button: UIButton {
  
  var title: String = "" {
    didSet{
      setTitle(title, for: .normal)
    }
  }
  
  var radius: CGFloat = 22 {
    didSet {
      layer.cornerRadius = radius
    }
  }
  
  var textColor: UIColor = Color.theme {
    didSet {
      setTitleColor(textColor, for: .normal)
    }
  }
  
  var backColor: UIColor = Color.btnNormal {
    didSet {
      backgroundColor = backColor
    }
  }
  
  var fonts: UIFont = HRFont(size: 15) {
    didSet {
      titleLabel?.font = fonts
    }
  }
  
  override init(frame: CGRect) {
    super.init(frame: frame)
    setViews()
  }
  
  required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }
  
  
  // MARK: - SetViews
  func setViews() {
    layer.cornerRadius = radius
    setTitleColor(UIColor.white, for: .normal)
    titleLabel?.font = fonts
    normal()
  }
  
  
  // MARK: - Action
  func hlight() {
    isEnabled = true
    backgroundColor = Color.btnHlight
  }
  
  func normal() {
    isEnabled = false
    backgroundColor = Color.btnNormal
  }
}
